/**
 * 项目名：五位一体化工安全信息平台
 * 日期：    2019-12-06 15:05:46
 * Copyright (c) 2015- joysuch-版权所有
 */

package com.joysuch.wwyt.bp.controller;

import cn.zlg.common.springmvc.validate.constraints.NotNull;
import com.joysuch.wwyt.bp.bean.*;
import com.joysuch.wwyt.bp.bean.safetyworkcert.BpWorkSafetyAppListBean;
import com.joysuch.wwyt.bp.bean.safetyworkcert.BpWorkSafetyAuditInBean;
import com.joysuch.wwyt.bp.entity.BpTaskList;
import com.joysuch.wwyt.bp.entity.BpWorkSafetyAuditTemplate;
import com.joysuch.wwyt.bp.entity.BpWorkSafetyCert;
import com.joysuch.wwyt.bp.entity.BpWorkSafetyMethodConfig;
import com.joysuch.wwyt.bp.enums.SafetyWorkStates;
import com.joysuch.wwyt.bp.enums.SafetyWorkTypes;
import com.joysuch.wwyt.bp.repository.BpTaskListDao;
import com.joysuch.wwyt.bp.repository.BpWorkSafetyAuditTemplateDao;
import com.joysuch.wwyt.bp.repository.BpWorkSafetyCertDao;
import com.joysuch.wwyt.bp.service.BpTaskListService;
import com.joysuch.wwyt.bp.service.BpWorkSafetyAuditService;
import com.joysuch.wwyt.bp.service.BpWorkSafetyCertService;
import com.joysuch.wwyt.core.bean.SimpleSelectListBean;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.common.util.PageDataUtils;
import com.joysuch.wwyt.core.support.Context;
import com.joysuch.wwyt.risk.entity.RiskEvaluationRepo;
import com.joysuch.wwyt.risk.repository.RiskEvaluationRepoDao;
import com.joysuch.wwyt.risk.service.RiskEvaluationRepoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.util.Assert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.transaction.Transactional;
import javax.validation.Valid;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/bp/work-safety-audit")
@Api(tags = "/bp/work-safety-audit 作业证审核")
public class BpWorkSafetyAuditController {

    private static final Logger logger = LoggerFactory.getLogger(BpWorkSafetyAuditController.class);

    @Autowired
    private BpWorkSafetyAuditService bpWorkSafetyAuditService;
    @Autowired
    private BpWorkSafetyCertService bpWorkSafetyCertService;
    @Autowired
    private BpWorkSafetyCertDao bpWorkSafetyCertDao;
    @Autowired
    private BpTaskListService taskListService;
    @Autowired
    private BpTaskListDao taskListDao;
    @Autowired
    private RiskEvaluationRepoService riskEvaluationRepoService;
    @Autowired
    private RiskEvaluationRepoDao riskEvaluationRepoDao;
    @Autowired
    private BpWorkSafetyAuditTemplateDao bpWorkSafetyAuditTemplateDao;

    //审核
    @RequestMapping("page")
    public Object page(Pageable page, BpWorkSafetyAuditListSearchBean condition) {
        try {
            page = PageDataUtils.addOrderByDesc(page, "id");
            Page<BpWorkSafetyAuditListBean> data = bpWorkSafetyAuditService.findByPage(page, condition);
            return ResultBean.pageData(data.getContent(), data.getTotalElements());
        } catch (Exception e) {
            logger.error("分页查询失败", e);
            return ResultBean.fail(101, "分页查询失败");
        }
    }

    //验收
    @RequestMapping("check-page")
    public Object checkPage(Pageable page, BpWorkSafetyAuditListSearchBean condition) {
        try {
            page = PageDataUtils.addOrderByDesc(page, "id");
            Page<BpWorkSafetyAuditListBean> data = bpWorkSafetyAuditService.findByPageCheck(page, condition);
            return ResultBean.pageData(data.getContent(), data.getTotalElements());
        } catch (Exception e) {
            logger.error("分页查询失败", e);
            return ResultBean.fail(101, "分页查询失败");
        }
    }

    @RequestMapping("pageAll")
    public Object pageAll(Pageable page, BpWorkSafetyAuditListSearchBean condition) {
        try {
            page = PageDataUtils.addOrderByDesc(page, "id");
            Page<BpWorkSafetyAuditListBean> data = bpWorkSafetyAuditService.findByPageAll(page, condition);
            return ResultBean.pageData(data.getContent(), data.getTotalElements());
        } catch (Exception e) {
            logger.error("分页查询失败", e);
            return ResultBean.fail(101, "分页查询失败");
        }
    }

    @RequestMapping("delete")
    public Object delete(Long id) {
        try {
            bpWorkSafetyAuditService.delete(id);
            return ResultBean.success("");
        } catch (Exception e) {
            logger.error("删除失败", e);
            return ResultBean.fail(101, "删除失败");
        }
    }

    @RequestMapping("audit")
    @Transactional
    public Object audit(@Valid @RequestBody BpWorkSafetyAuditInBean bean) {
        try {
            SafetyWorkTypes workTypes = SafetyWorkTypes.findByCode(bean.getType());
            Assert.notNull(workTypes, "不正确的任务类型");
            // BpWorkSafetyAudit audit = bpWorkSafetyAuditService.findByTypeAndWorkId(workTypes, id);
            BpWorkSafetyCert audit = bpWorkSafetyCertService.findById(bean.getId());
            //web app同时审核一张作业证,web后提交时,保留app审核结果
            if (audit.getState() == SafetyWorkStates.AUDIT_FAILED.getId() || audit.getState() == SafetyWorkStates.CHECK_ACCEPTED.getId()) {
                return ResultBean.success("app已经审核");
            }

            if (audit.getState() != 1) {
                // 只有待审核
                return ResultBean.fail(110, "当前状态不可以审核");
            }

            int stateInt = 0;
            if ("success".equals(bean.getState())) {
                stateInt = 2;
            } else {
                stateInt = 3;
            }
            // bpWorkSafetyAuditService.changeState(workTypes, id, stateInt, msg);
            audit.setState(stateInt);
            audit.setAuditUserId(Context.getCurrentUserId());
            audit.setAuditTime(new Date());
            audit.setAuditMsg(bean.getMsg());
            BpWorkSafetyCert save = bpWorkSafetyCertDao.save(audit);
            if ("success".equals(bean.getState())) {
                // 审核成功，更新状态
                if (audit.getJhaEvaluationId() != null) {
                    riskEvaluationRepoService.evaluationTakeEffect(audit.getJhaEvaluationId());
                }
            } else {
                if (audit.getJhaEvaluationId() != null) {
                    riskEvaluationRepoService.evaluationAuditFail(audit.getJhaEvaluationId());
                }
            }
            // 当作业证进行处理完成时候，再把代办事件进行更新
            // 根据用户ID查询
            List<BpTaskList> byId = taskListService.findById(save.getId());
            if (byId != null) {
                for (BpTaskList bpTaskList : byId) {
                    bpTaskList.setState(1);
                    bpTaskList.setDetail("作业审核");
                    bpTaskList.setHandleRemark(bean.getMsg());
                    // 处理当前时间
                    bpTaskList.setHandleTime(new Date());
                    bpTaskList.setHandleUserId(Context.getCurrentUserId());
                    taskListDao.save(bpTaskList);
                }
            }
            return ResultBean.success("");
        } catch (Exception e) {
            logger.error("审核失败", e);
            return ResultBean.fail(101, "审核失败:" + e.getMessage());
        }
    }

    // 验收
    @RequestMapping("check")
    @Transactional
    public Object check(@Valid @RequestBody BpWorkSafetyAuditInBean bean) {
        try {
            SafetyWorkTypes workTypes = SafetyWorkTypes.findByCode(bean.getType());
            Assert.notNull(workTypes, "不正确的任务类型");
            // BpWorkSafetyAudit audit = bpWorkSafetyAuditService.findByTypeAndWorkId(workTypes, id);
            BpWorkSafetyCert audit = bpWorkSafetyCertService.findById(bean.getId());
            if (audit.getState() == SafetyWorkStates.AUDIT_SUCCESS.getId() || audit.getState() == SafetyWorkStates.IN_WORK.getId()) {
                audit.setState(SafetyWorkStates.CHECK_ACCEPTED.getId());
                audit.setCheckUserId(Context.getCurrentUserId());
                audit.setCheckTime(new Date());
                audit.setCheckRemark(bean.getMsg());
                BpWorkSafetyCert save = bpWorkSafetyCertDao.save(audit);
                if (audit.getJhaEvaluationId() != null) {
                    RiskEvaluationRepo riskEvaluationRepo = riskEvaluationRepoDao.findByEvaluationId(audit.getJhaEvaluationId());
                    riskEvaluationRepoService.evaluationOutOfDate(riskEvaluationRepo.getId());
                }
                List<BpTaskList> byId = taskListService.findById(save.getId());
                if (byId != null) {
                    for (BpTaskList bpTaskList : byId) {
                        bpTaskList.setState(2);
                        bpTaskList.setDetail("作业证验收");
                        bpTaskList.setHandleRemark(bean.getMsg());
                        // 处理当前时间
                        bpTaskList.setHandleTime(new Date());
                        bpTaskList.setHandleUserId(Context.getCurrentUserId());
                        taskListDao.save(bpTaskList);
                    }
                }
                // bpWorkSafetyAuditService.changeCheckState(workTypes, id, stateInt, msg);
                return ResultBean.success("");
            } else {
                return ResultBean.fail(110, "当前状态不可以验收");
            }
        } catch (Exception e) {
            logger.error("验收失败", e);
            return ResultBean.fail(101, "验收失败");
        }
    }

    // 提交申请
    @RequestMapping("apply-for-audit")
    @Transactional
    public Object applyForAudit(@NotNull(field = "ID") Long id, @NotNull(field = "类型") String type) {
        try {
            SafetyWorkTypes workTypes = SafetyWorkTypes.findByCode(type);
            Assert.notNull(workTypes, "不正确的任务类型");
            BpWorkSafetyCert audit = bpWorkSafetyCertService.findById(id);

            if (audit.getState() != SafetyWorkStates.INITIAL.getId()
                    && audit.getState() != SafetyWorkStates.AUDIT_FAILED.getId()) {
                return ResultBean.fail(110, "当前状态不可以提交审核申请");
            }

            // 初始状态、审核失败状态，可以再次提交申请
            // bpWorkSafetyAuditService.changeState(workTypes, id, 1, null);
            audit.setState(SafetyWorkStates.WAITING_FOR_AUDIT.getId());
            audit.setApplyTime(new Date());
            BpWorkSafetyCert save = bpWorkSafetyCertDao.save(audit);
//            //审核流程模板
//            List<BpWorkSafetyAuditTemplate> tList = new ArrayList<>();
//            //对该类型作业证是否有审核模板进行判断
//            if (save.getType() != null && save.getWorkLevel() == null) {
//                tList = bpWorkSafetyAuditTemplateDao.findByType(save.getType());
//                if (CollectionUtils.isEmpty(tList)) {
//                    throw new IllegalArgumentException("当前作业未设置审核流程，请先设置审核流程");
//                }
//            } else if (save.getType() != null && save.getWorkLevel() != null) {
//                tList = bpWorkSafetyAuditTemplateDao.findByTypeAndWorkLevel(save.getType(), save.getWorkLevel());
//                if (CollectionUtils.isEmpty(tList)) {
//                    throw new IllegalArgumentException("当前作业未设置审核流程，请先设置审核流程");
//                }
//            }
            List<BpTaskList> byId = taskListService.findById(save.getId());
            if (byId != null) {
                for (BpTaskList bpTaskList : byId) {
                    bpTaskList.setState(0);
                    bpTaskList.setDataId(save.getId());
                    bpTaskList.setDetail("作业证审批");
                    bpTaskList.setUserId(save.getApplyUserId());
                    taskListDao.save(bpTaskList);
                }
            }
            return ResultBean.success("");
        } catch (Exception e) {
            logger.error("申请失败", e);
            return ResultBean.fail(101, "申请失败");
        }
    }

    //获取其他特殊作业证列表
    @GetMapping("getOtherSafetyWorkList")
    @ApiOperation(value = "获取其他特殊作业证列表")
    public ResultBean getOtherSafetyWorkList(Pageable page, OtherSafetyWorkSearchBean bean) {
        Page<BpOtherSafetyWorkSearchBean> p = bpWorkSafetyCertService.getOtherSafetyWorkList(page, bean);
        return ResultBean.pageData(p.getContent(), p.getTotalElements());
    }

    //获取作业证类型列表
    @GetMapping("getSafetyTypeList")
    @ApiOperation(value = "获取作业证类型列表")
    public ResultBean getSafetyTypeList() {
        List<SimpleSelectListBean> list = bpWorkSafetyCertService.getSafetyTypeList();
        return ResultBean.success(list);
    }

    //获取作业证状态列表
    @GetMapping("getSafetyStateList")
    @ApiOperation(value = "获取作业证状态列表")
    public ResultBean getSafetyStateList() {
        List<SimpleSelectListBean> list = bpWorkSafetyCertService.getSafetyStateList();
        return ResultBean.success(list);
    }

    //作业证安全措施配置
    //保存安全措施模板
    @PostMapping("/saveMethodTemplate")
    @ApiOperation(value = "保存安全措施模板")
    @RequiresPermissions("bp:work-safety-audit:saveMethodTemplate")
    public ResultBean addMethodTemplate(@RequestBody List<BpWorkSafetyMethodConfigBean> list) {
        List<BpWorkSafetyMethodConfig> configList = bpWorkSafetyCertService.saveMethodTemplate(list);
        return ResultBean.success(configList);
    }


    //查看安全措施模板
    @GetMapping("getMethodTemplateList")
    @ApiOperation(value = "查看安全措施模板")
    public ResultBean getMethodTemplateList(String type) {
        List<BpWorkSafetyMethodConfigBean> beanList = bpWorkSafetyCertService.getMethodTemplateList(type);
        return ResultBean.success(beanList);
    }


    //删除安全措施模板
    @GetMapping("deleteMethodTemplate")
    @ApiOperation(value = "删除安全措施模板")
    @RequiresPermissions("bp:work-safety-audit:deleteMethodTemplate")
    public ResultBean deleteMethodTemplate(Long id) {
        try {
            bpWorkSafetyCertService.deleteMethodTemplate(id);
            return ResultBean.success("");
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return ResultBean.fail(101, "删除失败");
        }

    }

    //作业审核模板设置
    //保存审核模板
    @PostMapping("/addTemplate")
    @ApiOperation(value = "保存审核模板")
    @RequiresPermissions("bp:work-safety-audit:addTemplate")
    public ResultBean addTemplate(@RequestBody BpWorkSafetyAuditTemplateBean bean) {
        BpWorkSafetyAuditTemplate template = bpWorkSafetyCertService.addTemplate(bean);
        return ResultBean.success(template);
    }


    //修改审核模板
    @PostMapping("/updateTemplate")
    @ApiOperation(value = "修改审核模板")
    @RequiresPermissions("bp:work-safety-audit:updateTemplate")
    public ResultBean updateTemplate(@RequestBody BpWorkSafetyAuditTemplateBean bean) {
        BpWorkSafetyAuditTemplate template = bpWorkSafetyCertService.updateTemplate(bean);
        return ResultBean.success(template);
    }

    //修改审核模板状态
    @GetMapping("/updateTemplateState")
    @ApiOperation(value = "修改审核模板状态")
    @RequiresPermissions("bp:work-safety-audit:updateTemplateState")
    public ResultBean updateTemplateState(Long id, Integer state) {
        try {
            bpWorkSafetyCertService.updateTemplateState(id, state);
            return ResultBean.success("template");
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
            return ResultBean.fail(101, "模板状态修改失败");
        }
    }

    //查看审核模板列表
    @GetMapping("/findTemplateList")
    @ApiOperation(value = "查看审核模板列表")
    public ResultBean findTemplateList() {
        List<BpWorkSafetyAuditTemplateBean> bean = bpWorkSafetyCertService.findTemplateList();
        return ResultBean.success(bean);
    }

    //查看审核模板
    @GetMapping("/findTemplateById")
    @ApiOperation(value = "查看审核模板")
    public ResultBean findTemplateById(@RequestParam(value = "templateId") Long templateId) {
        BpWorkSafetyAuditTemplateBean bean = bpWorkSafetyCertService.findTemplateById(templateId);
        return ResultBean.success(bean);
    }


    //作业证web,app审核
    @PostMapping("/safetyAudit")
    @ApiOperation(value = "作业证web,app审核")
    public ResultBean safetyAudit(@RequestBody @Validated BpWorkSafetyWebAuditBean bean) {
        try {
            bpWorkSafetyCertService.safetyAudit(bean);
            return ResultBean.success("");
        } catch (Exception e) {
            logger.error("作业证id:" + bean.getCertId() + "->{" + e.getMessage() + "}", e);
            return ResultBean.fail(101, "审核失败");
        }
    }

    // 查询app审核页面
    @GetMapping("/getAppAuditById")
    @ApiOperation(value = "查询app审核页面")
    public ResultBean getAppAuditById(@RequestParam(value = "certId") Long certId) {
        try {
            BpWorkSafetyAppAuditListBean bean = bpWorkSafetyCertService.getAppAuditById(certId);
            return ResultBean.success(bean);
        } catch (Exception e) {
            logger.error("作业证id:" + certId + "->{" + e.getMessage() + "}", e);
            return ResultBean.fail(101, "查询失败");
        }
    }

    //app验收
    @PostMapping("/checkApp")
    @ApiOperation(value = "app验收")
    // @RequiresPermissions("bp:work-safety-audit:checkApp")
    public ResultBean checkApp(@RequestBody BpWorkSafetyAppAuditBean bean) {
        try {
            BpWorkSafetyCert audit = bpWorkSafetyCertService.findById(bean.getCertId());
            if (audit.getState() == SafetyWorkStates.AUDIT_SUCCESS.getId() || audit.getState() == SafetyWorkStates.IN_WORK.getId()) {
                Integer flag = bpWorkSafetyCertService.checkApp(bean);
                return ResultBean.success(flag);
            } else {
                return ResultBean.fail(110, "当前状态错误,不可以进行申请");
            }
        } catch (Exception e) {
            logger.error("作业证id:" + bean.getCertId() + "->{" + e.getMessage() + "}", e);
            return ResultBean.fail(110, "验收失败");
        }
    }

    // 查询app验收页面
    @GetMapping("/getAppCheckById")
    @ApiOperation(value = "查询app验收页面")
    public ResultBean getAppCheckById(@RequestParam(value = "certId") Long certId) {
        try {
            BpWorkSafetyAppAuditBean bean = bpWorkSafetyCertService.getAppCheckById(certId);
            return ResultBean.success(bean);
        } catch (Exception e) {
            logger.error("作业证id:" + certId + "->{" + e.getMessage() + "}", e);
            return ResultBean.fail(101, "查询失败");
        }
    }

    //app申请页面列表展示
    @GetMapping("/getAppApplyList")
    @ApiOperation(value = "app申请页面列表展示")
    public ResultBean getAppApplyList(Pageable pageable) {
        return bpWorkSafetyCertService.getAppApplyList(pageable);
    }

    //app待审核页面列表展示
    @GetMapping("/getAppWaitAuditList")
    @ApiOperation(value = "app待审核页面列表展示")
    public ResultBean getAppWaitAuditList(Pageable pageable, String codeOrLevel, Integer state) {
        return bpWorkSafetyCertService.getAppWaitAuditList(pageable, codeOrLevel, state);
    }

    //app待验收页面列表展示
    @GetMapping("/getAppWaitCheckList")
    @ApiOperation(value = "app待验收页面列表展示")
    public ResultBean getAppWaitCheckList(Pageable pageable) {
        return bpWorkSafetyCertService.getAppWaitCheckList(pageable);
    }


    // 增加作业审核危害辨识
    @PostMapping("/saveIdentify")
    @ApiOperation(value = "增加作业审核危害辨识")
    public ResultBean saveIdentify(@RequestBody BpWorkSafetyIdentifyBean bean) {
        BpWorkSafetyCert audit = bpWorkSafetyCertService.findById(bean.getCertId());
        if (audit.getState() != SafetyWorkStates.WAITING_FOR_AUDIT.getId()) {
            return ResultBean.fail(110, "当前状态错误,不可以进行申请");
        }
        Long id = bpWorkSafetyCertService.saveIdentify(bean);
        return ResultBean.success(id);
    }


    //保存措施确认
    @PostMapping("/saveStep")
    @ApiOperation(value = "保存措施确认")
    public ResultBean saveStep(@RequestBody @Validated BpWorkSafetySigenerBean bean) {
        Long id = bpWorkSafetyCertService.saveStep(bean);
        return ResultBean.success(id);
    }

//
//    //保存动火审核分析
//    @PostMapping("/saveFileAnalyze")
//    @ApiOperation(value = "保存动火审核分析")
//    public ResultBean saveFileAnalyze(@RequestBody BpWorkSafetyFileAnalyzeBean bean) {
//        Long id = bpWorkSafetyCertService.saveFileAnalyze(bean);
//        return ResultBean.success(id);
//    }
//
//    //保存受限空间分析
//    @PostMapping("/saveSpaceAnalyze")
//    @ApiOperation(value = "保存受限空间审核分析")
//    public ResultBean saveSpaceAnalyze(@RequestBody BpWorkSafetySpaceAnalyzeBean bean) {
//        Long id = bpWorkSafetyCertService.saveSpaceAnalyze(bean);
//        return ResultBean.success(id);
//    }
//
//    //保存签字确认
//    @PostMapping("/saveSinger")
//    @ApiOperation(value = "保存签字确认")
//    public ResultBean saveSinger(@RequestBody BpWorkSafetySigenerAddBean bean) {
//        Long id = bpWorkSafetyCertService.saveSinger(bean);
//        return ResultBean.success(id);
//    }


    // 查询作业审核危害辨识
    @GetMapping("/getIdentifyById")
    @ApiOperation(value = "查询作业审核危害辨识")
    public ResultBean getIdentifyById(@RequestParam(value = "identifyId") Long identifyId) {
        BpWorkSafetyIdentifyBean bean = bpWorkSafetyCertService.getIdentifyById(identifyId);
        return ResultBean.success(bean);
    }

    // 查看措施确认签字表
    @GetMapping("/getStep")
    @ApiOperation(value = "查看措施确认签字表")
    public ResultBean getStep(@RequestParam(value = "certId") Long certId) {
        List<BpWorkSafetySigenerBean> list = bpWorkSafetyCertService.getStep(certId);
        return ResultBean.success(list);
    }

    // 查看动火审核分析
    @GetMapping("/getFileAnalyze")
    @ApiOperation(value = "查看动火审核分析")
    public ResultBean getFileAnalyze(@RequestParam(value = "certId") Long certId) {
        List<BpWorkSafetyFileAnalyzeBean> list = bpWorkSafetyCertService.getFileAnalyze(certId);
        return ResultBean.success(list);
    }

    // 查看受限空间审核分析
    @GetMapping("/getSpaceAnalyze")
    @ApiOperation(value = "查看受限空间审核分析")
    public ResultBean getSpaceAnalyze(@RequestParam(value = "certId") Long certId) {
        List<BpWorkSafetySpaceAnalyzeBean> list = bpWorkSafetyCertService.getSpaceAnalyze(certId);
        return ResultBean.success(list);
    }

    //查看作业证签字表
    @GetMapping("/getAppSigner")
    @ApiOperation(value = "查看作业证签字表")
    public ResultBean getAppSigner(@RequestParam(value = "certId") Long certId) {
        List<BpWorkSafetySigenerAddBean> list = bpWorkSafetyCertService.getAppSigner(certId);
        return ResultBean.success(list);
    }

    // 删除动火审核分析
    @GetMapping("/deleteFileAnalyze")
    @ApiOperation(value = "删除动火审核分析")
    public ResultBean deleteFileAnalyze(@RequestParam(value = "id") Long id) {
        try {
            bpWorkSafetyCertService.deleteFileAnalyze(id);
            return ResultBean.success("");
        } catch (Exception e) {
            return ResultBean.fail(101, "删除失败");
        }
    }

    // 删除受限空间审核分析
    @GetMapping("/deleteSpaceAnalyze")
    @ApiOperation(value = "删除受限空间审核分析")
    public ResultBean deleteSpaceAnalyze(@RequestParam(value = "id") Long id) {
        try {
            bpWorkSafetyCertService.deleteSpaceAnalyze(id);
            return ResultBean.success("");
        } catch (Exception e) {
            return ResultBean.fail(101, "删除失败");
        }
    }

    //查看作业证签字表
    @GetMapping("/getSigner")
    @ApiOperation(value = "查看作业证签字表")
    public ResultBean getSigner(@RequestParam(value = "certId") Long certId, @RequestParam(value = "categoryId") Integer categoryId) {
        List<BpWorkSafetySigenerBean> list = bpWorkSafetyCertService.getSigner(certId, categoryId);
        return ResultBean.success(list);
    }

    //app审核
    @GetMapping("/appAudit")
    @ApiOperation(value = "作业证审核")
    public ResultBean appAudit(@RequestParam(value = "certId") Long certId
            , @RequestParam(value = "sTime") Date sTime, @RequestParam(value = "eTime") Date eTime, @RequestParam(value = "checkMessage") String checkMessage) {
        bpWorkSafetyCertService.appAudit(certId, sTime, eTime, checkMessage);
        return ResultBean.success("");
    }

}
